#!/usr/bin/python

import sys
from Bio.SeqIO import QualityIO

seqdict = SeqIO.index(sys.argv[1], "fasta")
qualdict = SeqIO.index(sys.argv[2], "qual")

listfile = sys.argv[2]
te = open(listfile, "rU")
toextract = te.readlines()

for e in toextract:
    s = e.strip()
    if s in seqdict:
        print ">" + s
        print seqdict[s].seq
